package com.ruoyi.business.rabbitmq.publisher;

import com.ruoyi.business.rabbitmq.po.CollectDataInfo;
import com.ruoyi.business.rabbitmq.po.SignalInfo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Publisher {

    @Autowired
    @Qualifier("firstRabbitTemplate")
    private RabbitTemplate firstRabbitTemplate;

    @Autowired
    @Qualifier("secondRabbitTemplate")
    private RabbitTemplate secondRabbitTemplate;

    public void publishSignal(String exchangeName, SignalInfo signalInfo) {
        firstRabbitTemplate.convertAndSend(exchangeName, "", signalInfo);
        secondRabbitTemplate.convertAndSend(exchangeName, "", signalInfo);
    }

    public void publishData(String exchangeName, List<CollectDataInfo> dataInfos) {
        firstRabbitTemplate.convertAndSend(exchangeName, "", dataInfos);
        secondRabbitTemplate.convertAndSend(exchangeName, "", dataInfos);
    }
}
